package com.mushiengine.core {
import asmock.framework.Expect;

import com.mushiengine.core.error.DiggbeError;
import com.mushiengine.test.MockTestCase;
import com.mushiengine.test.MyBeanLoader;

public class DiggbeTest extends MockTestCase{

    private var _mockBeanLoader:IBeanLoader;

    public function DiggbeTest() {
        super([
            IBeanLoader
        ]);
    }


    public override function setUp():void {
        super.setUp();

        _mockBeanLoader = IBeanLoader(mockRepository.createStrict(IBeanLoader));

        Diggbe.setBeanLoaderForTest(_mockBeanLoader);
    }

    public function testThatconstructorCannotBeCalled():void {
        try {
            var digg:Diggbe = new Diggbe();
            fail("should not reach this");
        } catch(e:DiggbeError) {
            assertTrue(true);
        }
    }

    public function testThatBeanLoaderGetDescriptionsIsCalled():void {
        var beanDef:MyBeanLoader = new MyBeanLoader();
        Expect.call(_mockBeanLoader.loadBeanDefinition(beanDef));
        mockRepository.replayAll();
        Diggbe.loadBeanDefinition(beanDef);
        mockRepository.verifyAll();
    }

    public function testThatBeanLoaderAddBeanIsCalled():void {
        var someObj:Object = new Object();

        Expect.call(_mockBeanLoader.addbean("key", someObj));
        mockRepository.replayAll();
        Diggbe.addbean("key", someObj);
        mockRepository.verifyAll();
    }


}
}